package com.sky.blog.test.util;

import com.sky.blog.util.SaltUtils;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.concurrent.CountDownLatch;

/**
 * @author sky  2022/3/26
 * @version 1.0
 */
@SpringBootTest
public class testSalt {

    @Test
    public void testGetSalt() {
        long startTime = System.currentTimeMillis();

        System.out.println(SaltUtils.getSalt());

        long endTime = System.currentTimeMillis();
        System.out.println("生成时间:" + (endTime - startTime) + "ms");
    }

    public static void main(String[] args) throws InterruptedException {
        CountDownLatch downLatch = new CountDownLatch(10000);
        long startT = System.currentTimeMillis();
        for (int i = 0; i < 1; i++) {
            new Thread(() -> {
                long startTime = System.currentTimeMillis();
                String salt = SaltUtils.getSalt();
                long endTime = System.currentTimeMillis();
                System.out.println(Thread.currentThread().getName() + " 的生成时间:" + (endTime - startTime) + "ms  ---> " + salt);
                downLatch.countDown();
            }, i + "").start();
        }
        downLatch.await();
        long endT = System.currentTimeMillis();
        System.out.println("总时间:" + (endT - startT) + "ms");
    }
}
